<template>
  <div>
    <el-dialog
      title="编辑"
      :visible="dialogVisible"
      width="30%"
      @close="cancelHandle">
      <el-form :model="formData" label-width="80px">
        <el-form-item label="名称">
          <el-input size="mini" v-model="formData.name" placeholder="请输入名称"></el-input>
        </el-form-item>
        <el-form-item label="年级">
          <el-select size="mini" v-model="formData.region" placeholder="请选择年级" class="full-width">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="班号">
          <el-input size="mini" v-model="formData.name" placeholder="请输入班号"></el-input>
        </el-form-item>
        <el-form-item label="标识">
          <el-input size="mini" v-model="formData.name" placeholder="请输入标识"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select size="mini" v-model="formData.region" placeholder="请选择是否在用" class="full-width">
            <el-option label="是" value="shanghai"></el-option>
            <el-option label="否" value="beijing"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button size="mini" @click="cancelHandle">取 消</el-button>
        <el-button size="mini" type="primary" @click="cancelHandle">确 定</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'UpdateView',
  props: ['updateVisible', 'updateData', 'type'],
  data () {
    return {
      dialogVisible: false,
      formData: {
        user: '',
        region: ''
      },
      formLabelWidth: '120px'
    }
  },
  mounted () {
    this.dialogVisible = this.updateVisible
    if (this.type === 'edit') {
      this.formData = this.updateData
    }
  },
  methods: {
    onSubmit () {
      console.log('submit!')
    },
    cancelHandle () {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped>
.full-width {
  width: 100%;
}
</style>
